package com.springboot.frame.starter.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

/**
 * @author liheng
 * @ClassName TimeDTO
 * @Description
 * @date 2021-05-24 14:42
 */
@ApiModel("时间dto")
public class TimeDTO {
    @ApiModelProperty("查询时间 格式 yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate searchTime;

    public String getSearchTime() {
        if (Objects.nonNull(searchTime)) {
            return searchTime.format(DateTimeFormatter.ofPattern(BasePageDTO.DATE_FORMATTER_DATE));
        }
        return null;
    }

    public void setSearchTime(LocalDate searchTime) {
        this.searchTime = searchTime;
    }

    @Override
    public String toString() {
        return "TimeDTO{" +
                "searchTime=" + searchTime +
                '}';
    }
}
